//
//  PaMailDetailSubjectCell.m
//  iOS_Router_Runtime
//
//  Created by 王水鑫 on 2018/11/1.
//  Copyright © 2018年 王水鑫. All rights reserved.
//

#import "PAMailDetailSubjectCell.h"
#import "UIColor+ColorChange.h"

static CGFloat const subjectTitleFont = 18;
static NSString * const subjectTitleTypeface = @"PingFangSC-Medium";
static CGFloat const timeLabelTitleFont = 14;
static NSString * const timeLabelTitleTypeface = @"PingFangSC-Regular";

@implementation PAMailDetailSubjectCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (instancetype)init {
    if (self = [super init]) {
        [self appendSubViews];
    }
    self.selectionStyle = UITableViewCellSelectionStyleNone; // 去掉点击阴影
    return self;
}
- (void)appendSubViews {
    self.mailTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(20, 8, [UIScreen mainScreen].bounds.size.width - 110, 26)];
    [self.mailTitleLab setFont:[UIFont fontWithName:subjectTitleTypeface size:subjectTitleFont]];
    self.mailTitleLab.textColor = [UIColor colorWithHexString:@"#333333"];
    [self addSubview:self.mailTitleLab];
    
    self.timeLab = [[UILabel alloc] initWithFrame:CGRectMake(20, 8 + 26 + 6, 300, 20)]; // 防止出现比例缩放高度找不到基数
    [self.timeLab setFont:[UIFont fontWithName:timeLabelTitleTypeface size:timeLabelTitleFont]];
    self.timeLab.textColor = [UIColor colorWithHexString:@"#999999"];
    [self addSubview:self.timeLab];
    
    [self appendIconSubViews];
}
- (void)appendIconSubViews {
    // icon tip
    UIView *iconContainer = [[UIView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 90, 0, 90, 30)];
    [self addSubview:iconContainer];
    
    //附件icon
    self.holdAttachmentImageView = [[UIImageView alloc] initWithFrame:CGRectMake(55, 7.5, 15, 15)];
    [self.holdAttachmentImageView setImage:[UIImage imageNamed:@"pamail_attachment"]];
    self.holdAttachmentImageView.contentMode = UIViewContentModeScaleAspectFit;
    [iconContainer addSubview:self.holdAttachmentImageView];
    
    //权限icon
    self.authorityImageViewRightConstraint = 20 + (15 + 7.5) * (self.holdAttachmentImageView.hidden ? 0 : 1);
    self.authorityTipImageView = [[UIImageView alloc] initWithFrame:CGRectMake(75 - self.authorityImageViewRightConstraint, 7.5, 15, 15)];
    [self.authorityTipImageView setImage:[UIImage imageNamed:@"pamail_authority_lock"]];
    self.authorityTipImageView.contentMode = UIViewContentModeScaleAspectFit;
    [iconContainer addSubview:self.authorityTipImageView];
    
    //旗标icon
    self.starImageViewRightConstraint = 20 + (15 + 7.5) * ((self.holdAttachmentImageView.hidden ? 0 : 1) + (self.authorityTipImageView.hidden ? 0 : 1));
    self.starMarkImageView = [[UIImageView alloc] initWithFrame:CGRectMake(75 - self.starImageViewRightConstraint, 7.5, 15, 15)];
    [self.starMarkImageView setImage:[UIImage imageNamed:@"pamail_flag_red"]];
    self.starMarkImageView.contentMode = UIViewContentModeScaleAspectFit;
    [iconContainer addSubview:self.starMarkImageView];
}

@end
